package de.cau.apo.samples;

import java.io.FileNotFoundException;
import java.io.IOException;

import de.cau.apo.CommunicationInterface;
import de.cau.apo.problems.strippacking.Rectangle;
import de.cau.apo.problems.strippacking.SPInstance;
import de.cau.apo.problems.strippacking.SPSolution;

public class StripPackingSample {

	public static void main(String[] args) throws FileNotFoundException, IOException {
		// create instance parse instance file
		SPInstance instance = new SPInstance();
		instance.parseInstance(CommunicationInterface.getInstance());
		// create solution by putting all the rectangles about each other at the left border
		SPSolution solution = new SPSolution(instance);
		float y = 0;
		for (Rectangle rect : instance.getRectangles()) {
			rect.setLocation(0, y);
			y += rect.getWidth();
		}
		// publish solution and do debug information output
		if (CommunicationInterface.publishSolution(solution)) {
			System.err.println("Solution is feasible");
		} else {
			System.err.println("Solution is not feasible");
		}
	}

}
